@use "sass:color";

$nav-bottom-padding: 1.5em;
$nav-tabs-link-padding: 1em 1.5em;
$nav-tabs-link-padding-mobile: 0.8em 1em;
$nav-tabs-background-color: $nav-background-color;
$tabs-height: 42px;
$tabs-height-mobile: 42px;
$nav-link-color: #1e1e1e; // Should this use $black instead?
$gradient-orange: #ffa500;

body {
  #react-container {
    display: flex;
    width: 100%;
  }

  nav[role="navigation"] {
    max-width: $sidenav-width;

    #side-nav {
      width: $sidenav-width;
      height: 100vh;
      display: flex;
      position: sticky;
      flex-direction: column;
      left: 0;
      top: 0;
      bottom: 0;
      font-family: "Roboto", sans-serif;
      border-right: 9px solid;
      border-image: linear-gradient(to bottom, $blue, $gradient-orange) 1 100%;
      background-color: $nav-background-color;
      z-index: 115;

      .sidebar-nav {
        padding: 1.2em;
        display: flex;
        text-align: right;
        flex-direction: column;
        align-items: flex-end;
        flex-grow: 1;
      }

      a {
        display: block;
        font-weight: normal;
        &,
        &:visited,
        &:hover,
        &:visited:hover {
          color: $blue;
        }
        &.active {
          text-decoration: underline;
          text-decoration-thickness: 2px;
          text-underline-offset: 6px;
          font-style: italic;
          font-weight: 700;
        }
      }

      .main-nav {
        font-size: 18px;
        flex-basis: 140px;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        margin-bottom: $nav-bottom-padding;
        font-weight: 500;
      }
      .navbar-bottom {
        margin-top: auto;
        font-size: 14px;
        .username {
          font-weight: 700;
          margin-bottom: 0.3em;
          // prevent long usernames from breaking the layout
          word-break: break-all;
          border-radius: 0;
        }
        line-height: 1.5em;

        > a {
          width: fit-content;
          margin-left: auto;
          font-weight: normal;
        }
      }
      .navbar-logo {
        z-index: 102; // just above the toggle hamburger button
      }
    }
    /* Sections of the sidebar navigation */
    .navbar-logo {
      height: auto;
      width: 40px;
      margin-bottom: $nav-bottom-padding;
    }
    // header shown on small screens, with button to open drawer menu
    .navbar-header {
      display: none;
      height: $navbar-height;
      border-bottom: 3px solid;
      border-image: linear-gradient(to right, $blue, $gradient-orange) 100% 1;

      .navbar-logo {
        margin: 0;
        margin-left: auto;
        margin-right: auto;
        width: auto;
        align-self: center;
        > img {
          height: 26px;
          margin-top: 3px;
        }
      }
      .navbar-toggler {
        z-index: 101; // just above so it can be clicked to close the side-nav
        margin-left: 15px;
        border-color: $blue;
        position: absolute;
        .icon-bar {
          background-color: $blue;
        }
        .navbar-toggler-icon {
          width: 2.5em;
          height: 2.5em;
        }
      }
    }

    .search-bar {
      background-color: #a4a2bf;
      height: 50px;
      input {
        font-size: 1.2rem;
        padding: 0.5rem 0.5rem 0.5rem 1rem;
        border-radius: 0;
        box-shadow: none;
        background-color: #a4a2bf;
        color: $blue;
      }
      input:-webkit-autofill,
      input:autofill {
        background-color: #a4a2bf !important;
      }
      button {
        border-radius: 0;
        box-shadow: none;
        padding-right: 1.2em;
        background-color: #a4a2bf;
        color: $blue;
      }
    }
  }
  /* main content */
  .container-react {
    // Leave some space for BrainzPlayer
    padding-bottom: $brainzplayer-height;

    width: 100%; // fallback
    width: calc(100% - $sidenav-width);

    [role="main"] {
      max-width: $max-content-width;
      margin-left: auto;
      margin-right: auto;
    }
  }

  /* Styles for mobile devices */
  @media (max-width: $offscreen-sidenav-breakpoint) {
    nav[role="navigation"] {
      max-width: unset;
      #side-nav {
        transition: transform 0.3s ease-in-out;
        position: fixed;
        height: auto;
        transform: translateX(-100%);
        &.show {
          transform: none;
        }
        .mobile-nav-fix {
          position: absolute;
          background-color: $nav-background-color;
          border-right: 9px solid $gradient-orange;
          //sidenav width + border thickness
          width: calc(100% + 9px);
          height: 120px;
          bottom: -110px;
          right: -9px; // parent's border thickness
          z-index: 99;
        }
      }
      #side-nav-overlay {
        content: "";
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s linear;
        position: fixed;
        width: 100vw;
        height: 110vh !important;
        top: 0;
        bottom: 0;
        right: 0;
        background: white;
        z-index: 114;
        &.show {
          opacity: 0.8;
          pointer-events: unset;
        }
      }
      .navbar-header {
        display: flex;
        align-items: center;
      }
    }
    .container-react {
      &,
      .container-react-main {
        width: 100%;
      }
    }
    #react-container {
      display: initial;
    }
  }
}

.secondary-nav {
  /* Secondary nav container should be full width and scrollable if there is excess */
  width: calc(100% + $grid-gutter-width);
  margin-left: calc($grid-gutter-width * -0.5 - 1px);
  margin-right: $grid-gutter-width * -0.5;
  margin-bottom: $nav-bottom-padding;
  &,
  > * {
    background-color: $nav-tabs-background-color;
  }

  .nav.nav-tabs {
    display: flex;
    background-color: $nav-tabs-background-color;
    white-space: nowrap;
    border-bottom: none;
    flex-wrap: nowrap;

    > li {
      background-color: $nav-tabs-background-color;
      border-bottom: 1px solid $nav-tabs-border-color;
      float: unset;
      > a {
        color: $nav-link-color;
        padding: $nav-tabs-link-padding;
        border: 1px solid $nav-tabs-border-color;
        border-top: none;
        border-bottom: none;
        margin-right: -1px;
        margin-bottom: 0px;
        &:hover {
          color: initial;
          &:not(.active) {
            background-color: #f9f6f5;
          }
        }
      }
      &.active > a {
        color: $nav-link-color;
        font-weight: 700;
        border-bottom: 1px solid white;
        margin-bottom: -1px;
      }
      &.username {
        font-weight: 700;
        background: linear-gradient(288deg, #46433a 16.96%, $blue 98.91%);
        color: $white;
        > * {
          padding: $nav-tabs-link-padding;
        }
        a,
        a:hover,
        a:visited,
        a:visited:hover {
          color: $white;
          background: initial;
        }
      }
      &.disabled {
        background-color: color.adjust(
          $nav-tabs-background-color,
          $lightness: -15%
        );
        > a {
          color: color.adjust($nav-tabs-background-color, $lightness: -35%);
        }
      }
    }
  }

  .breadcrumb {
    padding: $nav-tabs-link-padding;
    list-style: none;
    border-bottom: 1px solid $nav-tabs-border-color;
    > li {
      display: inline-block;
      color: $body-color;
      > a {
        color: $nav-link-color !important;
        font-weight: initial;
      }
      &.active {
        color: $blue;
        font-weight: 700;
      }
      & + li:before {
        padding: 0 5px;
        content: "\003E";
      }
    }
  }
  /* Styles for mobile devices */
  @media (max-width: $offscreen-sidenav-breakpoint) {
    /* When not all tabs fit horizontally,
		hide tabs behind gradient to indicate there's more */
    &::after {
      content: "";
      width: 4em;
      background: linear-gradient(270deg, #fff, transparent);
      position: absolute;
      pointer-events: none;
      right: 0;
      height: $tabs-height;
      margin-top: -$tabs-height;
    }

    .nav.nav-tabs > li {
      > a,
      &.username > * {
        padding: $nav-tabs-link-padding-mobile;
      }
    }
    .breadcrumb {
      padding: $nav-tabs-link-padding-mobile;
    }
  }
  /* Special styles for very wide screens */
  @media (min-width: $very-wide-screen-breakpoint) {
    > * {
      /* Align the secondary nav with the centered content */
      width: calc(100% - $sidenav-width);
      max-width: $max-content-width;
      margin-left: auto;
      margin-right: auto;
    }
    .nav.nav-tabs > li.username {
      background: #46433a;
    }
    .breadcrumb {
      padding-left: 0;
    }
  }
}

.tertiary-nav {
  /* This tertiary nav (pills at the top of the page) should be max full width and scrollable */
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 0 1em;
  margin-left: $grid-gutter-width * -0.5;
  margin-right: $grid-gutter-width * -0.5;
  &.dragscroll > * {
    flex-shrink: 0;
  }
}
.tertiary-nav-vertical {
  ul {
    padding-left: 1em;
    line-height: 2.2em;
    li {
      list-style: none;
    }
  }
}
#settings {
  display: flex;
  flex-wrap: wrap;
  .tertiary-nav-vertical {
    flex: 0;
    flex-basis: 250px;
  }
}
.profile-on-mb {
  float: right;
  margin-top: 20px;
}
.modal-backdrop {
  width: 100vw;
  max-width: initial;
  margin: 0;
  &:not(.show) {
    pointer-events: none;
  }
}
